<template>
<div>
  <detail-nav-bar></detail-nav-bar>
  <detail-swiper :top-images="topImages"></detail-swiper>
  <detail-base-info :goods="goods"></detail-base-info>
</div>
</template>

<script>
import DetailNavBar from "./childComps/DetailNavBar";
import DetailSwiper from "./childComps/Detailswiper";
import DetailBaseInfo from "./childComps/DetailBaseInfo";

import {getDetail,Goods} from "network/detail";

export default {
  name: "Detail",
  components:{
    DetailNavBar,
    DetailSwiper,
    DetailBaseInfo
  },
  data(){
    return {
      iid:null,
      topImages:[],
      goods: {}
    }
  },
  created() {
    //1.保存传入的id
    this.iid = this.$route.params.iid

    //2.根据iid请求详情数据
    getDetail(this.iid).then(res => {
      // console.log(res)
      // (1).获取顶部的轮播图数据
      const data = res.result
      this.topImages = data.itemInfo.topImages
      // (2).获取商品信息
      this.goods = new Goods(data.itemInfo,data.columns,data.shopInfo.services)

    })
  }
}
</script>

<style scoped>

</style>